import { IFeidaoAiBrowserComponent } from '@feidao/web/interfaces';
import local_get from '@feidao/web/atom/browser/local/get';
import local_set from '@feidao/web/atom/browser/local/set';

export default async function (fd: IFeidaoAiBrowserComponent, ...args: any[]) {
	const user_name = fd.data.node.querySelector('[data-feidao-id="user_name"]') as HTMLInputElement;
	const shanchu_name = fd.data.node.querySelector('[data-feidao-id="shanchu_name"]') as HTMLInputElement;
	const user_pwd = fd.data.node.querySelector('[data-feidao-id="user_pwd"]') as HTMLInputElement;
	const chakan_name = fd.data.node.querySelector('[data-feidao-id="chakan_name"]') as HTMLInputElement;
	const fl = await local_get(fd, 'fl');

	if (user_name.value != '') {
		shanchu_name.classList.remove('display-n');
	} else {
		shanchu_name.classList.add('display-n');
	}

	if (user_pwd.value != '') {
		if (fl == null) {
			user_pwd.type = 'password';
		} else if (fl == false) {
			user_pwd.type = 'password';
		} else if (fl == true) {
			user_pwd.type = 'text';
		}
		chakan_name.classList.remove('display-n');
	} else {
		user_pwd.type = 'password';
		chakan_name.classList.add('display-n');
		await local_set(fd, 'fl', false);
	}


}

